#include <stdio.h>
#include <stdlib.h>
typedef struct l
{
    int data[100];
    int len;
}l;
l *init(int n){
    l *lone=malloc(sizeof(l));
    lone->len=0;
    int sj;
    while (lone->len<n)
    {
        int sj;
        printf("输入一个数");
        scanf("%d",&sj);
        lone->data[lone->len]=sj;
        lone->len++;   
    }
    
    return lone;
}

int search(l l,int key ){
    int low=0,height=l.len,mid;
    while((height+1)>low){
        mid=(low+height)/2;
        if(l.data[mid]==key){
            return mid;
        }
        else if(l.data[mid]<key){
            low=mid+1;
        }
        else{
            height=mid-1;
        }
    }
    return -1;
}
void main(){
    l *l=init(8);
    for(int i=0;i<l->len;i++){
        printf("%d ",l->data[i]);
        if(i%5==0&&i>0){
            printf("\n");
        }
    }
    printf("输入一个数");
    int k;
    scanf("%d",&k);
    int r=search(*l,k);
    printf("%d",r);
}